<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        日期：{{date|formatterDate}}
    </div>
    <div id="app2">
        日期：{{date|formatterDate}}
    </div>
    <div id="app3">
        {{msg}}逆序输出：{{msg|formatterR}}
    </div>
    <script src="../vue.js"></script>
    <script>
        Vue.filter('formatterDate',function(val){
            console.log(val);
            let ary=val.split('/');
            let str1='0'+ary[1];
            return `${ary[0]}-${str1}-${ary[2]}`;
        })
        new Vue({
            el:'#app',
            data () {
                return {
                    date:'2021/5/23',
                }
            }
        });
        new Vue({
            el:'#app2',
            data () {
                return {
                    date:'2021/5/24',
                }
            }
        })
        new Vue({
            el:'#app3',
            data () {
                return {
                    msg:'hello',
                }
            },
            filters: {
                formatterR(val){
                    console.log(val.substr(1,3));     //ell
                    console.log(val.substring(1,3));  //el
                    return val.split('').reverse().join('');
                }
            }
        })
    </script>
</body>
</html>